package cn.wit.test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

import org.junit.Test;

public class Demo {
	
	@Test
	public void test() {
		
		String a = "中";
		System.out.println(Arrays.toString(a.getBytes()));
		
	}
	
	@Test
	public void test1() {
		
		try(FileOutputStream fo = new FileOutputStream("a.text")){
			
			//字节流，一次写一个字节，可能会丢失信息
			fo.write('中');
//			fo.write('A');
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	@Test
	public void test2() {
		
		try(FileInputStream fi = new FileInputStream("a.text")){
			
			byte[] bytes = new byte[10];
			
			int count = fi.read(bytes);
			
			System.out.println(count);
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
